﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Security.Cryptography;
using System.Collections.Specialized;
using System.IO;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Net;
using Cosmetic;
using Cosmetic.DataEntity;
using Cosmetic.Logic;

namespace WebApp.Shopping
{
    public partial class ReturnS : System.Web.UI.Page
    {
        PurchaseManager m_PurchaseManager = new PurchaseManager();
        UserManager m_UserManager = new UserManager();
        IntegralManager m_IntegralManager = new IntegralManager();
        protected void Page_Load(object sender, EventArgs e)
        { 
            string CustomerCode = "FM9999";

            if (Request.QueryString["TradeNo"] != null)
            {
                Order theOrder = m_PurchaseManager.GetOrderByTradeNo(Request.QueryString["TradeNo"]);

                if (theOrder != null)
                {
                    this.lbOrderNum.Text = Request.QueryString["TradeNo"].ToString();
                    this.lbPrice.Text = (theOrder.Price.Value + theOrder.DeliveryPrice.Value).ToString("F2");
                    theOrder.Valid = true;
                    m_PurchaseManager.ValidOrder(theOrder);
                    m_PurchaseManager.CreateOrderInHZ(Request.QueryString["TradeNo"].ToString(), CustomerCode, theOrder.PayType, "Admin");
                    m_PurchaseManager.CreateOrderDetailInHZ(Request.QueryString["TradeNo"].ToString());
                    return;
                }
            }
            else
            {
                Response.Redirect("~/home.aspx");
            }
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect(String.Format("alipaytos.aspx?TradeNo={0}", Request.QueryString["TradeNo"]));
        }

        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("~/home.aspx");
        }

        protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
        { 
            Response.Redirect("~/Space/BasicInfo.aspx");
        }
    }
}
